package org.cttic.visualization.visualization.util.sixUtil;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.cttic.visualization.visualization.common.module.provinceData;
import org.cttic.visualization.visualization.common.module.serviceCountData;
import org.cttic.visualization.visualization.util.AggregationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.cttic.visualization.visualization.common.module.provinceData;
import org.cttic.visualization.visualization.common.module.serviceCountData;
import org.cttic.visualization.visualization.common.module.serviceCountData.*;

import java.util.List;

/**
 * @author shkstart
 * @create 2020-06-02 16:10
 */
@Component
public class servicesCountUtil {
    @Autowired
    private AggregationUtil aggregationUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void servicesCountQueryUtil(String provinceId,String startTime,String endTime,List<pointTypeArr> list) {
        pointTypeArr.quotaIn quotaIn1 = new pointTypeArr.quotaIn();
        pointTypeArr.quotaIn quotaIn0 = new pointTypeArr.quotaIn();
        pointTypeArr pointTypeArr1 = new serviceCountData.pointTypeArr();
        pointTypeArr pointTypeArr0 = new serviceCountData.pointTypeArr();
        int start = Integer.parseInt(provinceId + "0000");
        int end = Integer.parseInt(provinceId + "9999");
        System.out.println("start:" + start);
        System.out.println("end:" + end);
        //收费站数量
        String count1 = aggregationUtil.queryCount(startTime, endTime,
                start, end,
                1
        );
        //门架数量
        String count0 = aggregationUtil.queryCount(startTime, endTime,
                start, end,
                2
        );
        //3-收费站  4-门架/省界门架
        quotaIn1.setPointType("3");
        quotaIn1.setServiceNums(count1);
        pointTypeArr1.setQuotaInfo(quotaIn1);
        pointTypeArr1.setProvinceId(provinceId);
        pointTypeArr1.setProvinceName(provinceData.provinceID.get(Integer.parseInt(provinceId)));


        quotaIn0.setPointType("4");
        quotaIn0.setServiceNums(count0);
        pointTypeArr0.setQuotaInfo(quotaIn0);
        pointTypeArr0.setProvinceId(provinceId);
        pointTypeArr0.setProvinceName(provinceData.provinceID.get(Integer.parseInt(provinceId)));
        list.add(pointTypeArr1);
        list.add(pointTypeArr0);
    }

}
